package com.itheima.config;

import com.itheima.interceptor.LogInterceptor;
import com.itheima.interceptor.LogInterceptor2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration //配置类
public class MvcConfig implements WebMvcConfigurer {


    @Autowired
    private LogInterceptor logInterceptor;
    @Autowired
    private LogInterceptor2 logInterceptor2;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(logInterceptor)//添加拦截器
        .addPathPatterns("/**")//设置拦截路径
        .excludePathPatterns("/a/b")//设置排除路径
        .order(1);//order表示优先级 数字越小，越先执行

        registry.addInterceptor(logInterceptor2)//添加拦截器
        .addPathPatterns("/**")//设置拦截路径
        .excludePathPatterns("/a/b")//设置排除路径
        .order(2);



    }
}
